package lianxi;

import java.util.Scanner;

public class 第二题 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int sum = 0;
        int num = 0;
        System.out.println("请输入密码");
        int password = scan.nextInt();
            while(password!=1111){
                System.out.println("请重新输入");
                password = scan.nextInt();
            }
        int command = 0;
        do {
            System.out.println("请输入功能：");
            System.out.println("1:取款");
            System.out.println("2.存款");
            System.out.println("3.查询余额");
            System.out.println("4.退卡");
            command = scan.nextInt();
            switch (command) {
                case 1:
                    System.out.println("请输入取款金额");
                    num = scan.nextInt();
                    sum -= num;
                    System.out.println("当前余额为" + sum);
                    System.out.println("请输入功能：1.取款 2.存款 3.查询余额 4.退卡");
                    break;
                case 2:
                    System.out.println("请输入存款金额");
                    num = scan.nextInt();
                    sum += num;
                    System.out.println("当前余额为" + sum);
                    System.out.println("请输入功能：1.取款 2.存款 3.查询余额 4.退卡");

            }
        }while(command!=4);
    }
}
//        Scanner scan = new Scanner(System.in);
//        do{
//        System.out.println("请输入功能：1.存款 2.取款 3.查询余额 4.退卡");
//        int command=0;
//            command = scan.nextInt();
//            switch (command) {
//                case 1:
//                    System.out.println("存款");
//                    break;
//                case 2:
//                    System.out.println("取款");
//                    break;
//                case 3:
//                    System.out.println("查询余额");
//                    break;
//                case 4:
//                    System.out.println("退卡");
//                    break;
//                default:
//                    System.out.println("输入错误，程序结束");
//            }
//        }while(command!=4);



